package com.dingwen.treasure.business.controller;

import com.dingwen.treasure.base.controller.BaseViewController;
import com.dingwen.treasure.base.pojo.vo.Result;
import com.dingwen.treasure.config.i18n.LocaleMessage;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.Locale;

/**
 * 国际化 控制器
 *
 * @author dingwen
 * @date 2022/05/03
 */

@Api(tags = "国际化")
@RestController
@Slf4j
@RequestMapping("locale")
public class LocaleController implements BaseViewController {

    /**
     * 区域设置消息
     */
    @Resource
    private LocaleMessage localeMessage;

    /**
     * 中文语言环境
     *
     * @return {@link Result}
     */
    @ApiOperation("中文")
    @GetMapping("cn")
    public Result<String> localeForChinese() {
        return success(localeMessage.get("HttpStatus.HTTP_OK", Locale.SIMPLIFIED_CHINESE));
    }

    /**
     * US
     *
     * @return {@link Result}
     */
    @ApiOperation("US")
    @GetMapping("us")
    public Result<String> localeForUS() {
        return success(localeMessage.get("HttpStatus.HTTP_OK", Locale.US));
    }
}
